/**
 *首页改版
 *Last Modfy:2016.03.08 author:lj
 */
$(function() {
    //每日精选
    picFuns("#day_choice", 0, ".prev", ".next", 4000, 0);
    //24小时直播预告
    //picFuns("#foreshow_con", 0, ".f_prev", ".f_next", 500000, 600);
   



});
//水平滚动
function picFuns(obj, num, arra, arrb, timea, timeb) {
    var sWidth = $(obj + " ul li").width(); //获取焦点图的宽度（显示面积）
    var len = $(obj + "  ul li").length; //获取焦点图个数
    var index = 0;
    var adTimer;
    // var timea = 5000; 
    $(obj + " ul").css("width", sWidth * (len));
    //intialize function
    function init() {
        $(obj).hover(function() {
            clearInterval(adTimer);
        }, function() {
            timer();
        })
        timer();
    }

    function showImg(index) {
        var newLeft = -index * sWidth;
        //首页每日精选切换效果
        if (obj == "#day_choice") {
            //超过一条数据的带切换效果
            if(len > 1){
                $(obj + " ul").stop().animate({
                    "left": newLeft
                }, timeb).fadeOut(300).fadeIn(300);
            }
            
        } else {
            $(obj + " ul").stop().animate({
                "left": newLeft
                
            }, timeb);
        }

    }


    function showTab(index) {
        $(obj + " .cut span").eq(index).addClass("show").siblings().removeClass("show");
    }

    function timer() {
        adTimer = setInterval(function() {
            index++;
            if (index == len - num) {
                index = 0;
            }
            showImg(index);
            showTab(index);
        }, timea);
    }
    $(arra).click(function() {
        index -= 1;
        if($(this).attr("class") == "f_prev"){
            if (index == -1) {
                index = 0;
            }
        }
        else{
            if (index == -1) {
                index = len - num - 1;
            }
        }
        
        showImg(index);
        showTab(index);
    });
    $(arrb).click(function() {
        index += 1;
        if($(this).attr("class") == "f_next"){
            if (index >= len-1) {
                    index = len-1;
                }

        }else{
            if (index == len - num) {
                    index = 0;
                }

        }
        showImg(index);
        showTab(index);
    });

    $(obj + " .cut span").hover(function() {
        index = $(this).index();
        showImg(index);
        showTab(index);
    });

    init();

}




//图片预加载
$(".lazy-loading").lazyload({
    placeholder: "/themes/ugo/images/2015/2015_public/grey.png",
    effect: "fadeIn",
    failurelimit: 10
});

/**
 *首页广告图轮播 
 *Last Modfy:2015.10.8 author:wxl
 */

<!--//--><![CDaTa[//><!--
var sp = new ScrollPic();
sp.scrollContId = "FS_Cont_01"; //内容容器ID
sp.arrLeftId = "FS_arr_left_01"; //左箭头ID
sp.arrRightId = "FS_arr_right_01"; //右箭头ID
sp.dotListId = "FS_numList_01"; //点列表ID
sp.dotClassName = ""; //点className
sp.dotOnClassName = "current"; //当前点className
sp.listType = ""; //列表类型(number:数字，其它为空)
sp.listEvent = "onmouseover"; //切换事件
sp.frameWidth = 1920; //显示框宽度
sp.pageWidth = 1920; //翻页宽度
sp.upright = false; //垂直滚动
sp.speed = 25; //移动速度(单位毫秒，越小越快)
sp.space = 70; //每次移动像素(单位px，越大越快)
sp.autoPlay = true; //自动播放
sp.autoPlayTime = 2; //自动播放间隔时间(秒)
sp.circularly = true;
sp.initialize(); //初始化    
//--><!]]>
/**
 *鼠标划上轮播广告图，出现左右箭头
 *Last Modfy:2015.10.8 author:wxl
 */



var scrollNumLenth = $(".scroll_num span").length;
if(scrollNumLenth>1){
    $('.scroll').hover(function() {
        $(this).find('.t').fadeIn(300);
    }, function() {
        $(this).find('.t').hide();
    })
}else{
    //判断焦点图为1张图时不显示左右箭头、焦点圆点、没有播放
    sp.autoPlay = false;
     $(".scroll_num span").hide()
}


